package itheima.d08;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();

        Collections.addAll( set,"葫芦娃","小懒懒", "小懒懒", "小懒懒", "小懒懒", "小懒懒", "小懒懒", "小懒懒", "小懒懒");
        System.out.println(set);

        List <String>list=new ArrayList<>();
        Collections.addAll(list,"小懒懒1", "小懒懒2", "小懒懒3", "小懒懒4","小懒懒5", "小懒懒6", "小懒懒7", "小懒懒8", "小懒懒9");
        System.out.println("乱序前"+list);
        Collections.shuffle(list);
        System.out.println("乱序后"+list);
        List<String> nums=new ArrayList<>();
        Collections.addAll(nums,"1","2","4","3","5","6","9","7","8");
        Collections.sort(nums);
        System.out.println("排序后："+nums);



        List<Dog> dogs=new ArrayList<>();
        Collections.addAll(dogs,
                new Dog("小花",4),
                new Dog("小王",2),
                new Dog("小吉",5));

        Collections.sort(dogs, (o1, o2) -> o1.getAge() - o2.getAge());

        System.out.println("排序后："+dogs);



       Dog dogmax= dogs.stream().max(Comparator.comparingInt(Dog::getAge)).orElse(null);
        System.out.println("年纪最大的是："+dogmax);






    }
}
